﻿using System.Windows.Input;
using Microsoft.Practices.Prism.Regions;
using YunBox2.Contracts;
using YunBox2.Contracts.Core;

namespace YunBox2.Client.Infrastructure.ViewModels
{
	public abstract class MainContentViewModel : DomainObject
	{
		protected readonly ClientContext SessionContext = ClientContext.Current;


		public abstract string Title
		{
			get;
		}

		public virtual IRegionManager ScopeRegionManager
		{
			get;
			set;
		}

		public virtual void RegisterCommands()
		{
		}

		public virtual void UnregisterCommands()
		{
		}

		#region 状态

		#endregion

		#region Home

		public virtual ICommand HomePageCommand
		{
			get
			{
				return CommonCommands.HomeCommand;
			}
		}

		#endregion

		#region 导航 

		public virtual bool IsShowNavigationButtons
		{
			get
			{
				return false;
			}
		}

		public virtual ICommand FirstCommand
		{
			get;
			set;
		}

		public virtual ICommand PreviousCommand
		{
			get;
			set;
		}

		public virtual ICommand NextCommand
		{
			get;
			set;
		}

		public virtual ICommand LastCommand
		{
			get;
			set;
		}

		#endregion

		#region  查询与筛选

		public virtual ICommand QueryCommand
		{
			get;
			set;
		}

		public virtual ICommand FilterCommand
		{
			get;
			set;
		}

		#endregion

		#region 编辑

		private bool _isCreating;

		private bool _isEditing;

		private bool _isEnableCreating;

		private bool _isEnableEditing;

		private bool _isEnableRemoving;

		public virtual bool IsShowEditButtons
		{
			get
			{
				return false;
			}
		}

		public virtual bool IsCreating
		{
			get
			{
				return _isCreating;
			}
			protected set
			{
				if (_isCreating != value)
				{
					_isCreating = value;
					RaisePropertyChanged("IsCreating", "IsEditing", "IsEnableCreating", "IsEnableEditing", "IsEnableRemoving", "IsEnableSaving", "IsEnableDiscard");
				}
			}
		}

		public virtual bool IsEditing
		{
			get
			{
				return IsCreating || _isEditing;
			}
			protected set
			{
				if (_isEditing != value)
				{
					_isEditing = value;
					RaisePropertyChanged("IsEditing", "IsEnableCreating", "IsEnableEditing", "IsEnableRemoving", "IsEnableSaving", "IsEnableDiscard");
				}
			}
		}

		public virtual bool IsEnableCreating
		{
			get
			{
				return !IsEditing && _isEnableCreating;
			}
			protected set
			{
				if (_isEnableCreating != value)
				{
					_isEnableCreating = value;
					RaisePropertyChanged("IsEnableCreating");
				}
			}
		}

		public virtual bool IsEnableEditing
		{
			get
			{
				return !IsEditing && _isEnableEditing;
			}
			protected set
			{
				if (_isEnableEditing != value)
				{
					_isEnableEditing = value;
					RaisePropertyChanged("IsEnableEditing");
				}
			}
		}

		public virtual bool IsEnableRemoving
		{
			get
			{
				return !IsEditing || _isEnableRemoving;
			}
			protected set
			{
				if (_isEnableRemoving != value)
				{
					_isEnableRemoving = value;
					RaisePropertyChanged("IsEnableRemoving");
				}
			}
		}


		public virtual bool IsEnableSaving
		{
			get
			{
				return IsEditing;
			}
		}

		public virtual bool IsEnableDiscard
		{
			get
			{
				return IsEditing;
			}
		}

		public virtual ICommand CreatingCommand
		{
			get;
			protected set;
		}

		public virtual ICommand EditingCommand
		{
			get;
			protected set;
		}

		public virtual ICommand RemovingCommand
		{
			get;
			protected set;
		}

		public virtual ICommand SavingCommand
		{
			get;
			protected set;
		}

		public virtual ICommand DiscardCommand
		{
			get;
			protected set;
		}

		#endregion

		#region 操作

		public virtual bool IsShowOperationButtons
		{
			get
			{
				return false;
			}
		}
		/// <summary>
		/// 提交
		/// </summary>
		public virtual ICommand SubmitingCommand
		{
			get;
			protected set;
		}
		/// <summary>
		/// 审核
		/// </summary>
		public virtual ICommand AuditingCommand
		{
			get;
			protected set;
		}

		/// <summary>
		/// 核准
		/// </summary>
		public virtual ICommand Approvingommand
		{
			get;
			protected set;
		}

		public virtual ICommand InvalidingCommand
		{
			get;
			protected set;
		}

		#endregion

		#region 输出
		public virtual bool IsShowExportButtons
		{
			get
			{
				return false;
			}
		}

		public virtual ICommand PrintingCommand
		{
			get;
			protected set;
		}

		public virtual ICommand PrintPreviewCommand
		{
			get;
			protected set;
		}

		public virtual ICommand ExportingCommand
		{
			get;
			protected set;
		}

		#endregion

		#region 关闭

		public virtual bool CanClose
		{
			get
			{
				return true;
			}
		}

		public virtual ICommand ClosingCommand
		{
			get
			{
				return CommonCommands.ActicedViewClosingCommand;
			}
		}

		public virtual ICommand ShutdownCommand
		{
			get
			{
				return CommonCommands.ApplicationShutdownCommand;
			}
		}

		#endregion
	}
}